﻿@model GPS.ENTITYS.CrudModelSMONHOC

@{
    ViewBag.Title = "Thêm Mới Môn Học";
}

<style type="text/css">
    .btn-file {
        position: relative;
        overflow: hidden;
    }

        .btn-file input[type=file] {
            position: absolute;
            top: 0;
            right: 0;
            min-width: 100%;
            min-height: 100%;
            font-size: 100px;
            text-align: right;
            filter: alpha(opacity=0);
            opacity: 0;
            background: red;
            cursor: inherit;
            display: block;
        }

    input[readonly] {
        background-color: white !important;
        cursor: text !important;
    }
</style>

@using (Html.BeginForm("Create", "GPS_MonHoc", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    <h3 class="text-center fdb-title-search-form">Thêm Mới Môn Học</h3>
    <div id="tabs-1">
        @Html.Hidden("IsEdit", 0)
        <fieldset class="fs_body">
            <legend class="head_title">Thông tin môn học</legend>
            <div class="row margin-top-05">
                <div class="col-md-4 control-label">
                    Tên Môn Học:<span style="color:red;">(*)</span>
                </div>
                <div class="col-md-8 control-txt">
                    @Html.TextBoxFor(model => model.MONHOC_TEN, new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.MONHOC_TEN)
                </div>
            </div>
            <div class="row margin-top-05">
                <div class="col-md-4 control-label">
                    Số VBPL:
                </div>
                <div class="col-md-8 control-txt">
                    @Html.TextBoxFor(model => model.MONHOC_VBPL, new { @class = "form-control" })
                </div>
            </div>
            <div class="row margin-top-05">
                <div class="col-md-4 control-label">
                    Mô Tả:
                </div>
                <div class="col-md-8 control-txt">
                    @Html.TextAreaFor(model => model.MONHOC_MOTA, new { @class = "form-control", @rows = 5 })
                </div>
            </div>
            <div class="row margin-top-05">
                <div class="col-md-4 control-label">
                    Trạng Thái:<span style="color:red;">(*)</span>
                </div>
                <div class="col-md-8 control-txt">
                    @Html.DropDownListFor(model => model.MONHOC_ACTIVE, new List<SelectListItem>
                                {
                                                    new SelectListItem() {Text = "--Lựa Chọn--", Value=""},
                                                    new SelectListItem() {Text = "Không Hiệu Lực", Value="0"},
                                                    new SelectListItem() {Text = "Hiệu Lực", Value="1"}

                                }, new { @class = "form-control" })
                </div>
            </div>
        </fieldset>
    </div>
    @*</div>*@
    <br />
    <div class="row">
        <div class="col-md-12">
            @*<input type="submit" value="Cập nhật" class="btn btn-info btn-sm" />*@
            <button type="submit" class="btn btn-danger btn-sm">
                <span class="glyphicon glyphicon-floppy-disk"></span> Cập nhật
            </button>
            &nbsp;&nbsp;
            @Html.ActionLink("Quay lại", "Index", null, new { @class = "btn btn-primary btn-sm" })
        </div>

    </div>
}

<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

<script src="~/Scripts/datepicker.js"></script>
<script src="~/Scripts/jquery-ui-1.11.4.js"></script>
<script src="~/Scripts/jquery.maskedinput.js"></script>
<script src="~/Scripts/jquery.maskMoney.js"></script>
<script src="~/Scripts/jquery.number.js"></script>
<script src="~/Scripts/jquery.masknumber.js"></script>
<script src="~/Scripts/moment.js"></script>

<script type="text/javascript">

    // Voi jQuery 1.9 > thi chi validate gia tri trong active tab
    // Muon validate nhung gia tri trong cac tab khac nua thi dung jquery.validate 1.8.1 or 1.7


    // mask edit cho truong ngay thang (su dung jquery.maskedinput)


    function ToJavaScriptDate(value) {
        if (value != null) {
            var pattern = /Date\(([^)]+)\)/;
            var results = pattern.exec(value);
            var dt = new Date(parseFloat(results[1]));
            return dt.getDate() + "/" + (dt.getMonth() + 1) + "/" + dt.getFullYear();
        }
        return null;
    }
</script>

<script type='text/javascript'>
    $(document).on('change', '.btn-file :file', function () {
        var input = $(this),
            numFiles = input.get(0).files ? input.get(0).files.length : 1,
            label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
        input.trigger('fileselect', [numFiles, label]);
    });

    function preview_image(event) {
        var reader = new FileReader();
        reader.onload = function () {
            var output = document.getElementById('output_image');
            output.src = reader.result;
        }
        reader.readAsDataURL(event.target.files[0]);
    }
</script>

<script type="text/javascript">
    $("#PT_NGAYGPXTL").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });

    $("#PT_NGAYHHGPXTL").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });

    $("#PT_NGAYGCNKD").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });

    $("#PT_NGAYHHGCNKD").datepicker({
        changeMonth: true,
        changeYear: true,

        dateFormat: 'dd/mm/yy'
    });

    $("#PT_NGAYGPXTL").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });
    $("#PT_NGAYHHGPXTL").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });
    $("#PT_NGAYGCNKD").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });
    $("#PT_NGAYHHGCNKD").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });

    // cho phep nhap so thap phan (su dung jquery.number)
    //$("#GV_THAMNIENLX").number(true, 2, '.', '');

</script>

@Styles.Render("~/Content/themes/base/css")

<script type="text/javascript">
    $(document).ready(function () {
        $('.btn-file :file').on('fileselect', function (event, numFiles, label) {

            var input = $(this).parents('.input-group').find(':text'),
                log = numFiles > 1 ? numFiles + ' files selected' : label;

            if (input.length) {
                input.val(log);
            } else {
                if (log) alert(log);
            }

        });
        @*$("#GV_NOICT_DVHC_MA").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/GPS_GiaoVien/AutoCompleteGV_NOICT_DVHC_MA",
                    type: "POST",
                    dataType: "json",
                    data: { term: request.term },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.DVHC_TENDAYDU, value: item.DVHC_MA };
                        }))


                    }
                })
            },
            messages: {
                noResults: "", results: ""
            }
        });


        $("#GV_DVGTVT_MA").change(function () {
            $.ajax({
                url: '@Url.Action("getGV_MA", "GPS_GiaoVien")',
                type: 'post',
                data: {
                    gv_DVGTVT_MA: $('#GV_DVGTVT_MA').val()
                }
            }).done(function (response) {

                $('#GV_MA').val(response);
            });
        });*@
    })
</script>
